package examples;

import helpers.CrawlerHelper;

import java.io.IOException;
import java.util.Calendar;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import search.ArticleSearchEngine;

import debugs.ArticleDebug;
import debugs.ArticleSearchDebug;

import entities.Article;
import entities.ArticleSearch;

import models.ArticleModel;

public class example1 extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		/*String id = request.getParameter("id");
		
		if (id != null) {
			ArticleModel articleModel = ArticleModel.getInstance();
			Article article = articleModel.getArticle(id);
			
			if (article != null) {
				ArticleDebug.debugWeb(article, response);
				ArticleSearch articleSearch = ArticleSearch.convert(article);
				ArticleSearchDebug.debugWeb(articleSearch, response);
			} else {
				response.getWriter().println("Not found article with id " + id);
			}
		} else {
			response.getWriter().println("id is null");
		}*/
		
		//Remove all search
		//ArticleSearchEngine.removeAllDocument();
		
		
		/*String content = CrawlerHelper.rewriteArticle("Generally the very first cause anyone does any sort of job is for the revenue. Girls that choose to turn out to be a table dancer are no distinct. The very first issue we do when we get a dancer application would be to locate out exactly why they want to be a dancer. A whole lot from the time that person is out of a job and desperate for income and has not really thought the choice out appropriately. For all those that have done their analysis you'll find quite a bit of choices accessible to understand pole dancing which include performing pole dancing courses.");
		response.getWriter().println(content);*/
		
	}
	
	/*public static void main(String[] args) {
		int startMonth = 1;
		int startYear = 2012;
		
		Calendar cal = Calendar.getInstance(); 
		int currentMonth = cal.get(Calendar.MONTH) + 1;
		int currentYear = cal.get(Calendar.YEAR);
		
		
		int countMonth = ((currentYear - startYear) * 12) + (currentMonth - startMonth);
		
		int month = currentMonth;
		int year = currentYear;
		for (int i = 0; i < countMonth + 1; i++) {
			System.out.println(month + " - " + year);
			
			month -= 1;
			if (month <= 0) {
				month = 12;
				year -= 1;
			}
		}
		
	}*/
	
	public static void main(String... aArgs){

	    int START = 1;
	    int END = 10;
	    System.out.println(getRandomNumberFrom(START, END));
	  }

	public static int getRandomNumberFrom(int min, int max) {
        Random foo = new Random();
        int randomNumber = foo.nextInt((max + 1) - min) + min;

        return randomNumber;

    }
}
